package com.jiang.daily.Q3335;

/**
 * @author Jiang
 * @version 1.0
 * @date 2025/05/13 23:23
 */
class Solution {
    private static final int MOD = 1000000007;

    public int lengthAfterTransformations(String s, int t) {
        int[] cnt = new int[26];
        for (char c: s.toCharArray()) {
            cnt[c - 'a']++;
        }

        for (int i = 0; i < t; i++) {
            int[] nxt = new int[26];
            nxt[0] = cnt[25];
            nxt[1] = (cnt[25] + cnt[0]) % MOD;
            for (int j = 2; j < 26; j++) {
                nxt[j] = cnt[j - 1];
            }
            cnt = nxt;
        }

        int res = 0;
        for (int i = 0; i < 26; i++) {
            res = (res + cnt[i]) % MOD;
        }

        return res;
    }
}
